package com.itheima.d6_jdk8_time;
import java.time.LocalDate;
import java.time.Month;

public class Test1_LocalDate {
    public static void main(String[] args) {
        // 0、获取本地日期对象(不可变对象)
        LocalDate now = LocalDate.now();
        System.out.println(now);
        // 1、获取日期对象中的信息(年，月，日，星期获取)
        int year = now.getYear();
         int month = now.getMonthValue();
        int dayOfMonth = now.getDayOfMonth();//一月中的第几天
        int dayOfYear = now.getDayOfYear();//一年中的第几天
        int value = now.getDayOfWeek().getValue();//星期几
        // 2、直接修改某个信息: withYear、withMonth、withDayOfMonth、withDayOfYear
        LocalDate localDate = now.withYear(2019);
        LocalDate localDate1 = now.withMonth(12);
        LocalDate localDate2 = now.withDayOfMonth(10);
        System.out.println(localDate2);
        LocalDate localDate3 = now.withDayOfYear(100);
        System.out.println(localDate3);
        // 3、把某个信息加多少: plusYears、plusMonths、plusDays、plusWeeks
        LocalDate localDate4 = now.plusDays(200);
        System.out.println(localDate4);
        LocalDate localDate5 = now.plusMonths(5);
        System.out.println(localDate5);
        LocalDate localDate6 = now.plusYears(2);
        LocalDate localDate7 = now.plusWeeks(3);
        System.out.println("--------");
        System.out.println(localDate7);
        // 4、把某个信息减多少：minusYears、minusMonths、minusDays、minusWeeks
        LocalDate localDate8 = now.minusDays(300);

        // 5、获取指定日期的LocalDate对象： public static LocalDate of(int year, int month, int dayOfMonth)
        LocalDate date = LocalDate.of(2019, 12, 4);
        System.out.println(date);
        // 6、判断2个日期对象，是否相等，在前还是在后： equals isBefore isAfter
        LocalDate date1 = LocalDate.of(2019, 12, 4);
        LocalDate date2 = LocalDate.of(2019, 11, 5);
        System.out.println("-------");
        System.out.println(date2.equals(date1));
        System.out.println(date2.isAfter(date1));
        System.out.println(date2.isBefore(date1));
    }
}
